#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
typedef long long ll;
using namespace std;
void extgcd(ll a,ll b,ll &d,ll &x,ll &y){
    if(!b){
        d=a;
        x=1;
        y=0;
    }
    else{
        extgcd(b,a%b,d,y,x);
        y-=x*(a/b);
    }
}
int main(void){
    //freopen("data.txt","r",stdin);
    ll x,y,m,n,L;
    ll x0,y0;
    while(~scanf("%lld%lld%lld%lld%lld",&x,&y,&m,&n,&L)){
        ll a=n-m;
        ll b=L;
        ll c=x-y;
        ll d=0;
        //printf("%lld %lld %lld\n",a,b,c);
        extgcd(a,b,d,x0,y0);
        //printf("%lld %lld %lld\n",d,x0,y0);
        if(c%d){
            printf("Impossible\n");
        }
        else{
            c/=d;
            ll ans=(c*x0%b+b)%b;
            //不取模的话这里x0是-1
            //ans=c*x0;
            //解出来的x0是ax+by=gcd(a,b)的一个解 c*x0才是ax+by=z的一个特解
            //模b也就是模L求出最小整数解
            printf("%lld\n",ans);
        }
    }
    return 0;
}